package com.example.demo.mapper;

import com.example.demo.model.MessageInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageInfoMapper {
    /**
     * 发布留言
     * @param messageInfo
     * @return
     */
    @Insert("insert into message_info (`from`, `to`, `message`) values (#{from}, #{to}, #{message})")
    Integer insertMessage(MessageInfo messageInfo);

    /**
     * 获取留言列表
     * @return
     */
    @Select("select `id`, `from`, `to`, `message`, `delete_flag`, `create_time`, `update_time` " +
            "from message_info where delete_flag = 0")
    List<MessageInfo> selectAllMessageInfo();
}
